// 手写深拷贝
function deepCopy(obj) {
  if (typeof obj !== "object") return obj;
  let newObj = Array.isArray(obj) ? [] : {};
  for (let key in obj) {
    if (obj.hasOwnProperty(key)) {
      newObj[key] = typeof obj[key] === "object" ? deepCopy(obj[key]) : obj[key];
    }
  }
  return newObj;
}

const obj = {
  name: 'tom',
  age: 10,
  father: {
    name: 'father',
    age: 30
  }
};

const newObj = deepCopy(obj);
console.log(newObj === obj);
console.log(newObj);
console.log(obj);
newObj.father.name = "aaa";
console.log(newObj);
console.log(obj);
